#!/bin/bash
#

# 判断参数
if [ -z $1 ]; then
   echo "帮助: $0 <IO|SQL>"
   exit 99
fi

# 根据参数截取IO、SQL线程的状态
state=$(mysql -uroot -pWWW.1.com -e "show slave status\G" 2> /dev/null | grep "Slave_${1}_Running:" | awk '{print $2}')

case $state in
   Yes)
      echo 1
      ;;
   No)
      echo 0
      ;;
esac
